<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
    
      <el-form-item label="申请单号" prop="sqh">
        <el-input
          v-model="queryParams.sqh"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
        <el-form-item label="身份证号码" prop="sfzh">
        <el-input
          v-model="queryParams.sfzh"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
       <el-form-item label="日期" prop="dateTime">
          <el-date-picker
          clearable
            v-model="queryParams.dateTime"
            type="daterange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
      </el-form-item>
      <el-form-item label="被评估人" prop="xm">
        <el-input
          v-model="queryParams.xm"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
       <el-form-item label="评估人" prop="pingname">
        <el-input
          v-model="queryParams.pingname"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
          <el-form-item label="居委-街道" >
            <el-select v-model="queryParams.streetid"  placeholder="请选择" @change="setNeighborhoodCommittee2" clearable>
                <el-option
                  v-for="item in streetList"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                  >
                </el-option>
              </el-select>        
               <el-select v-model="queryParams.juweiId"  placeholder="请选择" v-if="queryParams.streetid !=null && queryParams.streetid !=undefined" clearable>
                <el-option
                  v-for="item in neighborhoodCommittee2"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                  >
                </el-option>
              </el-select>      
            </el-form-item>
      <el-form-item label="评估类型" prop="pglx">
        <el-select v-model="queryParams.pglx" clearable placeholder="请选择评估类型">
            <el-option label="初次评估" :value="1" />
            <el-option label="复核评估" :value="2" />
            <el-option label="状态评估" :value="3" />
            <el-option label="期末评估" :value="4" />
            <el-option label="绿色通道" :value="5" />
            <el-option label="终核评估" :value="6" />
          </el-select>
      </el-form-item>
       <el-form-item label="护理类型" prop="fwlx">
         <el-select v-model="queryParams.fwlx" placeholder="请选择护理类型" clearable>
            <el-option label="养老机构照护" :value="0" />
            <el-option label="社区居家照护" :value="1" />
            <el-option label="住院理疗护理" :value="2" />
          </el-select>
      </el-form-item>
       <el-form-item label="申请日期" prop="sqrq">
        <el-date-picker
        clearable
          v-model="queryParams.sqrq"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="标签" prop="label">
        <el-input
          v-model="queryParams.label"
          placeholder="请输入标签"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <br>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" v-hasPermi="['sen:haveBeenAssessed:list']">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="handleAdd"
          v-hasPermi="['sen:haveBeenAssessed:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['assess:main:remove']"
        >删除</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
       <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="download"
          v-hasPermi="['sen:haveBeenAssessed:download']"
        >下载</el-button>
      </el-col>
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-download"
          size="mini"
          @click="filesUpload = true"
          v-hasPermi="['assess:main:remove']"
        >上传</el-button>
      </el-col> -->
      <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-upload2"
          size="mini"
          @click="handleDelete"
          v-hasPermi="['assess:main:remove']"
        >批量派单</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          size="mini"
          @click="batchUpdateLevel = true"
          v-hasPermi="['sen:haveBeenAssessed:batchUpload']"
        >批量上传等级</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="mainList" @selection-change="handleSelectionChange" @filter-change="filterHandler">
      <el-table-column show-overflow-tooltip type="selection" width="55" align="center" />
      <el-table-column show-overflow-tooltip label="月序号" align="center" prop="xh" width="80px"/>
      <el-table-column show-overflow-tooltip label="申请单号" align="center" prop="sqh" width="200"/>
      <el-table-column show-overflow-tooltip label="被评估人" align="center" prop="xm" width="120"/>
      <el-table-column show-overflow-tooltip label="评估人" align="center" prop="pingname"  :filters="filter" column-key="data" width="120"> 
          <template slot-scope="scope">
          <span  ><i class="el-icon-edit" @click="showAssessRen(scope.row)"></i>&nbsp;<span v-if="scope.row.pingname!=null">{{scope.row.pingname}} </span></span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="街道-居委" align="center" prop="neighborhoodCommittee" width="140">
        <template slot-scope="scope">
          <span ><i @click="showUpdateNeighborhooCommittee(scope.row)" class="el-icon-edit"></i>&nbsp;<span v-if="scope.row.neighborhoodCommittee!=null && scope.row.neighborhoodCommittee !=''">{{scope.row.neighborhoodCommittee}}</span></span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="评估完成时间" align="center" width="150" prop="submtime"  sortable> 
        <template slot-scope="scope">
          <span>{{formatDate(scope.row.submtime) }}</span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="派单时间" align="center" width="150" prop="sendSingleTime"  sortable>
        <template slot-scope="scope">
          <span>{{ formatDate(scope.row.paidanTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="标签" align="center" prop="label" >
          <template slot-scope="scope">
          <el-tag @click="updateLable(scope.row)" v-if="scope.row.label!=null && scope.row.label!=''" >{{scope.row.label}}</el-tag>
          <span v-else @click="updateLable(scope.row)">无</span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="状态" align="center" prop="status" sortable
        :filters="[{text: '已评估', value: '已评估'}, {text: '已录入', value: '已录入'}]"
        column-key="status"
      >
         <template slot-scope="scope">
          <span>{{ scope.row.status == 0 ?"待评估" : scope.row.status == 1 && scope.row.isluru == 1? " 已录入" :scope.row.status == 1? "已评估 ": scope.row.status == 2?"申请取消":"已取消"}}</span>
          &nbsp;
          <a style="color:blue;" v-if="scope.row.status == 3  " @click="showCause(scope.row.cancelreason)">原因</a>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="支付情况" align="center" prop="ispay" width="100" 
         :filters="[{text: '微信', value: '1'}, {text: '支付宝', value: '2'}, {text: '现金', value: '3'}]"
        column-key="pay"
      >
           <template slot-scope="scope">
          <span>{{ scope.row.ispay == 0 ?" " : scope.row.ispay == 1? "微信": scope.row.ispay == 2?"支付宝":"现金"}}</span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="预估等级" align="center" prop="yupgdj" sortable width="100">
        <template slot-scope="scope">
          <span>{{ scope.row.yupgdj == -1?" ": scope.row.yupgdj}}</span>
        </template>
      </el-table-column>
      <el-table-column show-overflow-tooltip label="评估等级" align="center" prop="pgdj" sortable width="100"
          :filters="[{text: '0', value: '0'},{text: '1', value: '1'}, {text: '2', value: '2'}, {text: '3', value: '3'}, {text: '4', value: '4'}, {text: '5', value: '5'}, {text: '6', value: '6'}]"
        column-key="pgdj"
      >
         <template slot-scope="scope"> 
          <span :style="scope.row.pgdjStatus == 0 || scope.row.pgdjStatus == null?'color:blue':'color:black'" @click="updateLevel2(scope.row)">{{ scope.row.pgdjStatus == 0 || scope.row.pgdjStatus == null? "初评": scope.row.pgdj}}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="220">
        <template slot-scope="scope">
           <el-button
            size="mini"
            type="text"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['sen:haveBeenAssessed:update']"
          >编</el-button>
             <el-button
            size="mini"
            type="text"
            icon="el-icon-document-checked"
            @click="zizujian(scope.row)"
          ></el-button>
          <el-button
            size="mini"
            type="text"
            @click="updateStatusMethods(scope.row)"
            v-hasPermi="['sen:haveBeenAssessed:update']"
          >改</el-button>
          <el-button
            size="mini"
            type="text"
            
            @click="showUpdateImage(scope.row)"
            v-hasPermi="['sen:haveBeenAssessed:update:image']"
          >图</el-button>
           <el-button
            size="mini"
            type="text"
            :style="scope.row.isRemark!=null &&scope.row.isRemark!=''?'color:red':null"
            :title="scope.row.isRemark"
            @click="showRemark(scope.row.id)"
            v-hasPermi="['sen:haveBeenAssessed:backups']"
          >备</el-button>
          <el-button
            size="mini"
            type="text"
            v-hasPermi="['sen:haveBeenAssessed:download']"
            @click="xia(scope.row)"
          >下</el-button>
          <el-button
            size="mini"
            type="text"
            @click="showJIlu(scope.row)"
            v-if="scope.row.logTotal !=null && scope.row.logTotal !=0"
            v-hasPermi="['sen:haveBeenAssessed:log']"
          >记录（{{scope.row.logTotal}}）</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改评估主对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules"  label-width="180px" height >
        <el-form-item label="申请号" prop="sqh">
          <el-input v-model="form.sqh" placeholder="请输入申请号" />
        </el-form-item>
        <el-form-item label="姓名" prop="xm">
          <el-input v-model="form.xm" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="性别" prop="xb">
            <el-radio v-model="form.xb" :label="1">男</el-radio>
            <el-radio v-model="form.xb" :label="2">女</el-radio>
        </el-form-item>
        <el-form-item label="出生年月" prop="csny">
          <el-input v-model="form.csny" placeholder="请输入出生年月" />
        </el-form-item>
        <el-form-item label="身份证号" prop="sfzh">
          <el-input v-model="form.sfzh" placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item label="社保卡号" prop="sbkh">
          <el-input v-model="form.sbkh" placeholder="请输入社保卡号" />
        </el-form-item>
        <el-form-item label="地址" prop="sxdz">
          <el-input v-model="form.sxdz" placeholder="请输入地址" />
        </el-form-item>
        <el-form-item label="居住区县代码" prop="zzjd">
            <el-input v-model="form.zzjd" placeholder="请输入居住街道代码" />
        </el-form-item>
        <el-form-item label="居住居委代码" prop="zzjd">
            <el-input v-model="form.zzjw" placeholder="请输入居住居委代码" />
        </el-form-item>
        <el-form-item label="电话号码" prop="dhhm">
          <el-input v-model="form.dhhm" placeholder="请输电话号码" />
        </el-form-item>
        <el-form-item label="手机号码" prop="sjhm">
          <el-input v-model="form.sjhm" placeholder="请输入手机号码" />
        </el-form-item>
         <el-form-item label="社保类型" prop="pglx">
          <el-select v-model="form.sblx" placeholder="社保类型" clearable>
            <!-- <el-option label="养老机构照护" :value="0" />
            <el-option label="社区居家照护" :value="1" />
            <el-option label="住院理疗护理" :value="2" /> -->
            <el-option label="职保/人保" :value="1" />
            <el-option label="非长护险人员" :value="2" />
            <el-option label="本市老红军、离休干部、革命伤残军人" :value="3" />
            <el-option label="互助帮困人员" :value="4" />
            <el-option label="复评" :value="5" />
          </el-select>
        </el-form-item>
         <el-form-item label="评估类型" prop="pglx">
          <el-select v-model="form.pglx" placeholder="请选择评估类型" clearable>
            <el-option label="初次评估" :value="1" />
            <el-option label="复核评估" :value="2" />
            <el-option label="状态评估" :value="3" />
            <el-option label="期末评估" :value="4" />
            <el-option label="绿色通道" :value="5" />
            <el-option label="终核评估" :value="6" />
          </el-select>
        </el-form-item>
         <el-form-item label="居委-街道" >
            <el-select v-model="form.streetid"  placeholder="请选择" @change="form.juweiId = null">
                <el-option
                  v-for="item in streetList"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                  >
                </el-option>
              </el-select>        
               <el-select v-model="form.juweiId"  placeholder="请选择" v-if="form.streetid!=null" clearable>
                <el-option
                  v-for="item in neighborhoodCommittee"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                  >
                </el-option>
              </el-select>      
            </el-form-item>
        <el-form-item label="护理类型" prop="fwlx">
          <el-select v-model="form.fwlx" placeholder="请选择护理类型" clearable>
            <el-option label="养老机构照护" :value="0" />
            <el-option label="社区居家照护" :value="1" />
            <el-option label="住院理疗护理" :value="2" />
          </el-select>
        </el-form-item>
        <el-form-item label="代办人名称" prop="dbrxm">
          <el-input v-model="form.dbrxm" placeholder="请输入代办人名称" />
        </el-form-item>
        <el-form-item label="代办人电话号码" prop="dbrdhhm">
          <el-input v-model="form.dbrdhhm" placeholder="请输入代办人电话号码" />
        </el-form-item>
        <el-form-item label="代办人手机号码" prop="dbrsjhm">
          <el-input v-model="form.dbrsjhm" placeholder="请输入代办人手机号码" />
        </el-form-item>
        <el-form-item label="代办人身份证号码" prop="dbrsfzh">
          <el-input v-model="form.dbrsfzh" placeholder="请输入代办人身份证号码" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">保存</el-button>
      </div>
    </el-dialog>
    <el-dialog title="修改" :visible.sync="updateImage" width="800px">
        <el-row :gutter="20" style="text-align:center">
          <el-col :span="8">
            <!-- <el-upload
              class="avatar-uploader"
              :action="baseURL"
              :show-file-list="false"
              :on-success="handleAvatarSuccessImage1"
              :before-upload="beforeAvatarUpload"> -->
              <img v-if="imageObject.image1" :src="imageObject.image1" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <!-- </el-upload> -->
            <div style="text-align:center">评估对象照片</div>
          </el-col>
          <el-col :span="8">
            <!-- <el-upload
              class="avatar-uploader"
              :action="baseURL"
              :show-file-list="false"
              :on-success="handleAvatarSuccessImage2"
              :before-upload="beforeAvatarUpload"> -->
              <img v-if="imageObject.image2" :src="imageObject.image2" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <!-- </el-upload> -->
            <div style="text-align:center">评估对象签名</div>
          </el-col>
          <el-col :span="8">
            <!-- <el-upload
              class="avatar-uploader"
              :action="baseURL"
              :show-file-list="false"
              :on-success="handleAvatarSuccessImage3"
              :before-upload="beforeAvatarUpload"> -->
              <img v-if="imageObject.image3" :src="imageObject.image3" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <!-- </el-upload> -->
            <div style="text-align:center">病例、药物等记录</div>
          </el-col>
        </el-row>
        <br>
        <el-row :gutter="20" style="text-align:center">
          <el-col :span="8">
            <!-- <el-upload
              class="avatar-uploader"
              :action="baseURL"
              :show-file-list="false"
              :on-success="handleAvatarSuccessImage4"
              :before-upload="beforeAvatarUpload"> -->
              <img v-if="imageObject.image4" :src="imageObject.image4" class="avatar">
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <!-- </el-upload> -->
            <div style="text-align:center">病例、药物等记录</div>
          </el-col>
          <el-col :span="8">
            <!-- <el-upload
              class="avatar-uploader"
              :action="baseURL"
              :show-file-list="false"
              :on-success="handleAvatarSuccessImage5"
              :before-upload="beforeAvatarUpload"> -->
                            <video v-if="imageObject.image5" controls :src="imageObject.image5" class="avatar"></video>
              <!-- <img v-if="imageObject.image5" :src="imageObject.image5" class="avatar"> -->
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <!-- </el-upload> -->
            <div style="text-align:center">视频1</div>
          </el-col>
          <el-col :span="8">
            <!-- <el-upload
              class="avatar-uploader"
              :action="baseURL"
              :show-file-list="false"
              :on-success="handleAvatarSuccessImage6"
              :before-upload="beforeAvatarUpload"> -->
              <video v-if="imageObject.image6" :src="imageObject.image6" controls class="avatar"></video>
              <!-- <img v-if="imageObject.image6" :src="imageObject.image6" class="avatar"> -->
              <i v-else class="el-icon-plus avatar-uploader-icon"></i>
            <!-- </el-upload> -->
            <div style="text-align:center">视频2</div>
          </el-col>
        </el-row>
        <br>
        <div style="text-align:center">
        <el-button type="primary" round @click="updateImages">提交</el-button>
        </div>
    </el-dialog>

    <el-dialog title="修改" :visible.sync="updateStatus" width="800px">
      <el-form ref="form" :model="updateStatusObj" label-width="120px">
        <el-form-item label="评估完成时间">
           <el-date-picker
            v-model="updateStatusObj.pgwcsj"
            type="datetime"
            placeholder="选择日期时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="评估状态">
          <el-select v-model="updateStatusObj.status" placeholder="请选择" clearable>
            <el-option label="待评估" :value="0"></el-option>
            <el-option label="已录入" :value="1"></el-option>
            <el-option label="待取消" :value="2"></el-option>
            <el-option label="已取消" :value="3"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">保存</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-dialog title="备注" :visible.sync="remark" width="800px">
      <el-form ref="form" :model="remarkObj">
        <el-form-item label="备注">
            <el-input v-model="remarkObj.remark" style="width:300px"/>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="addRemarkMethods">保存</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :data="remarkList"
        stripe
        height="300px"
        style="width: 100%">
        <el-table-column show-overflow-tooltip
          prop="ctype"
          label="类型"
          >
          <template slot-scope="scope">
            <span>{{ scope.row.ctype == 1?"评估员":"管路员"}}</span>
          </template>
        </el-table-column>
        <el-table-column show-overflow-tooltip
          prop="name"
          label="名称"
          >
        </el-table-column>
          <el-table-column show-overflow-tooltip
          prop="dttime"
          label="备注时间"
          >
        </el-table-column>
          <el-table-column show-overflow-tooltip
          prop="remark"
          label="内容"
          >
        </el-table-column>
      </el-table>
    </el-dialog>
     <el-dialog title="修改" :visible.sync="updateAssessRen" width="800px">
      <el-form ref="form" :model="remarkObj" label-width="100px">
        <el-form-item label="评估人">
          <div v-for="(item,index) in updateAssessRenList" :key="item.id"><span>{{item.xm}}</span>&nbsp;<span style="color:blue" @click="delteList(index)" v-if="item.xm!=null">删除</span></div>
        </el-form-item>
        <el-form-item label="添加一项">
          <el-select v-model="addPgy" placeholder="请选择" value-key="id" clearable filterable>
            <el-option v-for="item  in pgyList" :label="item.xm+'   '+item.zslx" :key="item.id" :value="item"></el-option>
          </el-select>
          <el-button type="success" icon="el-icon-check" circle @click="addPgyMethods"></el-button>
        </el-form-item>
      </el-form>
      <el-row>
        <el-button type="primary" @click="sendOrder">保存并派单</el-button>
      </el-row>
    </el-dialog>
     <el-dialog title="修改" :visible.sync="updateNeighborhooCommittee" width="800px">
      <el-form ref="form" :model="remarkObj" label-width="100px">
        <el-form-item label="街道-居委">
          <el-select v-model="updateNeighborhooCommitteeObj.streetid"  placeholder="请选择" @change="setNeighborhoodCommittee3">
                <el-option
                  v-for="item in streetList"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                  >
                </el-option>
              </el-select>        
               <el-select v-model="updateNeighborhooCommitteeObj.juweiId"  placeholder="请选择" v-if="updateNeighborhooCommitteeObj.streetid !=null && updateNeighborhooCommitteeObj.streetid !=undefined" clearable>
                <el-option
                  v-for="item in neighborhoodCommittee3"
                  :key="item.id"
                  :label="item.title"
                  :value="item.id"
                  >
                </el-option>
              </el-select>      
        </el-form-item>
      </el-form>
      <el-row>
        <el-button type="primary" @click="updateJieWei">保存</el-button>
      </el-row>
    </el-dialog>
    <el-dialog :visible.sync="filesUpload" width="800px" title="上传">
      <el-upload
        class="upload-demo"
        ref="upload"
                :action="uploadExcelUrl"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :file-list="fileList"
        :auto-upload="false">
        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
      </el-upload>
      <br>
      <span style="color:blue" @click="downloadFile">下载模板</span>
      <br>
      <div style="text-align:right">
        <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="batchUpdateLevel" width="800px" title="选择文件">
      <el-upload
        class="upload-demo"
        ref="batchUpdateLevel"
                :action="updateExcelUpdateLevel"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :on-success="successSendOrder"
        :file-list="fileList"
        :auto-upload="false">
        <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
      </el-upload>
      <br>
        <el-checkbox v-model="checked">评级提现</el-checkbox>
        <br>
      <span style="color:blue" @click="batchUpdateLevelMode">下载模板</span>
      <br>
      <div style="text-align:right">
        <el-button style="margin-left: 10px;" size="small" type="success" @click="batchUpdateLevelSubmit">上传到服务器</el-button>
      </div>
    </el-dialog>
     <el-dialog title="修改" :visible.sync="updateLevel" width="800px">
      <el-form ref="form" :model="remarkObj" label-width="100px">
        <el-form-item label="等级">
          <el-select v-model="updateLevelObj.pgdj" placeholder="请选择">
            <el-option label="0" :value="0"></el-option>
            <el-option label="1" :value="1"></el-option>
            <el-option label="2" :value="2"></el-option>
            <el-option label="3" :value="3"></el-option>
            <el-option label="4" :value="4"></el-option>
            <el-option label="5" :value="5"></el-option>
            <el-option label="6" :value="6"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-row>
        <el-button type="primary" @click="updateLeveMethods">修改</el-button>
      </el-row>
    </el-dialog>
      <el-dialog title="记录" :visible.sync="jilu" width="800px">
       <el-table
        :data="jiluList"
        style="width: 100%">
        <el-table-column show-overflow-tooltip
          prop="uname"
          label="用户"
          >
        </el-table-column>
        <el-table-column show-overflow-tooltip
          prop="tag"
          label="操作"
          >
        </el-table-column>
        <el-table-column show-overflow-tooltip
          prop="dtime"
          label="时间">
          <template slot-scope="scope">
            <span>{{formatDateStr(scope.row.dtime)}}</span>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="修改" :visible.sync="updateLableShow" width="800px" >
      <el-form ref="form" :model="remarkObj" label-width="100px" style="height:300px">
        <el-select
          v-model="updateLableList"
          multiple
          filterable
          allow-create
          default-first-option
          placeholder="请选择标签">
        </el-select>
        <el-button type="primary" @click="updateLabelMethods">提交</el-button>
      </el-form>  
    </el-dialog>
    <ASSESSNEBT ref="ASSESSNEBT"></ASSESSNEBT>
  </div>
</template>

<script>
import { listMain, getMain, delMain, addMain, updateMain,updateLabel, exportMain,updateImage,addRemark,queryRemarkList,queryAllPgy ,actionlogList,queryFiltration } from "@/api/assess/main";
import { listStreet } from "@/api/assess/street";
import axios from 'axios';
import ASSESSNEBT from './assessment.vue'
import qs from 'qs'
export default {
  name: "Main",
  components:{
    ASSESSNEBT
  },
  data() {
    return {
       updateLableShow:false,
      updateLableObj:{},
      updateLableList:[],
      
      batchUpdateLevel:false,
      batchUpdateObj:{},
      batchUpdateLevel:false,
      checked:false,
      jilu:false,
      updateLevel:false,
      updateLevelObj:{},
      updateNeighborhooCommitteeObj:{juweiId:null,streetid:null,id:null},
      updateNeighborhooCommittee:false,
      neighborhoodCommittee3:[],
      addPgy:{},
      updateAssessRen:false,
      updateAssessRenList:[],
      updateAssessRenObj:{},
      remarkObj:{},
      updateStatus:false,
      updateStatusObj:{},
       filter:[],
      querFilter:[],
      baseURL: process.env.VUE_APP_BASE_URL +"/public/image/upload",
      uploadExcelUrl: process.env.VUE_APP_BASE_URL +"/public/excel/upload",
      updateExcelUpdateLevel: process.env.VUE_APP_BASE_URL +"/public/forms/updateLevel",
      imageObject:{
        image1:null,
        image2:null,
        image3:null,
        image4:null,
        image5:null,
        image6:null,
      },
      fileList:[],
      remark: false,
      value1: [],
      updateImage: false,
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 评估主表格数据
      mainList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      filesUpload:false,
      downloadUrl: process.env.VUE_APP_BASE_URL +"/public/forms/Download",
      xiaUrl: process.env.VUE_APP_BASE_URL +"/public/forms/download/value",
      // 查询参数
      queryParams: {
        juweiId:null,
        pageNum: 1,
        pageSize: 10,
        type: null,
        streetid:null,
        serialNumber: null,
        requestCode: null,
        assesseeName: null,
        assesseeLandlinePhone: null,
        assesseePhone: null,
        assesseeSex: null,
        assesseeIdCard: null,
        assessessType: null,
        agentName: null,
        agentLandlinePhone: null,
        agentPhone: null,
        agentIdCard: null,
        socialSecurityCardNumber: null,
        socialSecurityType: null,
        serviceType: null,
        evaluatorIdOne: null,
        evaluatorOneName: null,
        evaluatorIdTwo: null,
        evaluatorTwoName: null,
        streetId: null,
        streetName: null,
        committeeId: null,
        committeeName: null,
        appointmentTime: null,
        assessCompletionTime: null,
        sendSingleTime: null,
        label: null,
        payoutStatus: null,
        forecastLevel: null,
        assessLevel: null,
        operationTotal: null,
        reasonCancellation: null,
        isRemark: null,
      },
            ispays:[],
      statuss:[],
      pgdj:[],
      jiluList:[],
      pgyList:[],
      remarkList:[],
      streetList:[],
      neighborhoodCommittee:[],
      
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        requestCode: [
          { required: true, message: "申请单号不能为空", trigger: "blur" }
        ],
        assesseeName: [
          { required: true, message: "被评估人名称不能为空", trigger: "blur" }
        ],
        assessessType: [
          { required: true, message: "评估类型(0:初次评估，1:复核评估 2:状态评估 3:期末评估 4:绿色通道 5:终核评估)不能为空", trigger: "change" }
        ],
        operationTotal: [
          { required: true, message: "操作记录条数不能为空", trigger: "blur" }
        ],
        isRemark: [
          { required: true, message: "是否有备注(0:没有 1:有)不能为空", trigger: "blur" }
        ],
        delFlag: [
          { required: true, message: "删除标志不能为空", trigger: "blur" }
        ]
      },
      neighborhoodCommittee2:[],
    };
  },
  created() {
    this.getList();
    this.getstreet();
    queryAllPgy({}).then(response => {
          this.pgyList = response.rows;
    });
    this.getFilters();
  },
  watch:{
    "form.streetid"(newValue,ObjValu){
      if(newValue == null){
        return;
      }
      for(let i = 0;i<this.streetList.length;i++){
        if(this.streetList[i].id == this.form.streetid){
          this.neighborhoodCommittee = this.streetList[i].list;
          return;
        }
      }

    }
  },
  methods: {
    
    updateLable(value){
      this.updateLableObj = {};
      this.updateLableObj.fid = value.id;
      if(value.label!=null && value.label!=''){
        this.updateLableList = value.label.split(",");
      }else{
      this.updateLableList = [];
      }
      this.updateLableShow = true;
    },
    updateLabelMethods(){
      if(this.updateLableList!=null && this.updateLableList.length>0){
        this.updateLableObj.cont = String(this.updateLableList);
      }
      updateLabel(this.updateLableObj).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.updateLableShow = false;
              this.getList();
        });
    },
    showJIlu(value){
      actionlogList({formid:value.id}).then(response => {
        this.jiluList = response.rows;
        this.jilu = true;
      });
    },
    updateLevel2(val){
      this.updateLevelObj = {id:val.id,pgdj:null};
      if(val.pgdj!=0){
        this.updateLevelObj.pgdj  = val.pgdj;
      }
      this.updateLevel = true;
    },
    updateLeveMethods(){
      this.updateLevelObj.jiesuan = 1;
          updateMain(this.updateLevelObj).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.updateLevel = false;
              this.getList();
        });
    },
     submitUpload() {
        this.$refs.upload.submit();
      },
      batchUpdateLevelSubmit() {
        this.$refs.batchUpdateLevel.submit();
      },
      handleRemove(file, fileList) {
        console.log(file, fileList);
      },
      handlePreview(file) {
        console.log(file);
      },
     handleChange(file, fileList) {
        this.fileList = fileList.slice(-3);
      },
    showUpdateNeighborhooCommittee(value){
      this.updateNeighborhooCommitteeObj = {};
      this.updateNeighborhooCommitteeObj.id = value.id;
      this.updateNeighborhooCommittee  = true;
    },
    batchUpdateLevelMode(){
       let url = "https://yumyoung.com/web/static/importExcel/批量上传等级模板.xlsx"
        const a = document.createElement('a')
        a.href = url
        a.download = "批量上传等级模板.xlsx" // 下载后文件名
        a.style.display = 'none'
        document.body.appendChild(a)
        a.click() // 点击下载
        document.body.removeChild(a) // 下载完成移除元素
    },
     batchSendOrdersMode(){
       let url = "https://yumyoung.com/web/static/importExcel/批量派单.xlsx"
        const a = document.createElement('a')
        a.href = url
        a.download = "批量派单.xlsx" // 下载后文件名
        a.style.display = 'none'
        document.body.appendChild(a)
        a.click() // 点击下载
        document.body.removeChild(a) // 下载完成移除元素
    },
    downloadFile(){
       let url = "https://yumyoung.com/web/static/importExcel/待评估人员上传模板.xlsx"
        const a = document.createElement('a')
        a.href = url
        a.download = "待评估人员上传模板.xlsx" // 下载后文件名
        a.style.display = 'none'
        document.body.appendChild(a)
        a.click() // 点击下载
        document.body.removeChild(a) // 下载完成移除元素
    },
    filterHandler(value,row,column){
      if(value.data!=null){
        this.querFilter=value.data;
      }
      if(value.pay!=null){
        this.ispays =value.pay;
      }
      if(value.status!=null){
        this.statuss =value.status;
      }
       if(value.pgdj!=null){
        this.pgdj =value.pgdj;
      }
      this.getList();
    },
    sendOrder(){
      let pingname = null;
      let pinguid = null;
      if(this.updateAssessRenList == null || this.updateAssessRenList.length == 0){
                      this.$message('评估人不能为空');
                      return;
      }
      for(let i = 0;i<this.updateAssessRenList.length;i++){
        if(pingname ==null){
          pingname = this.updateAssessRenList[i].xm;
        }else{
          pingname += ","+this.updateAssessRenList[i].xm;
        }
        if(pinguid ==null){
          pinguid = this.updateAssessRenList[i].id;
        }else{
          pinguid +=","+this.updateAssessRenList[i].id;
        }
      }

        updateMain({"id":this.updateAssessRenObj.id,"pinguid":pinguid,"pingname":pingname}).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.getList();
              this.updateAssessRen = false;
        });

    },
    showAssessRen(val){
        this.updateAssessRenList = [];
        this.updateAssessRenObj.id = val.id;
        if(val.pingname == null || val.pinguid == null || val.pingname == '' || val.pinguid == ''){
        }else{
        let name = val.pingname.split(",");
        let uid = val.pinguid.split(",");
        for (let i = 0 ;i<name.length;i++){
          this.updateAssessRenList.push({"id":uid[i],"xm":name[i]}); 
        }}
        this.updateAssessRen  = true;
    },
    addPgyMethods(){
         if(this.addPgy == null || this.addPgy == undefined){
        return;
      }else{
        if(this.addPgy.id == null || this.addPgy.xm == null){
          return;
        }
      }
      if(this.updateAssessRenList !=null && this.updateAssessRenList.length == 2){
          return;
      }else {
        if(this.updateAssessRenList !=null && this.updateAssessRenList ==1){
          if(this.updateAssessRenList[0].id == this.addPgy.id){
            return;
          }
        }
      }
   
      this.updateAssessRenList.push({"id":this.addPgy.id,"xm":this.addPgy.xm});
    },
    updateStatusMethods(val){
      this.updateStatusObj = {};
      this.updateStatus = true;
      this.updateStatusObj.id = val.id;
    },
    getNowDate(val) {
      const timeOne =val;
      const year = timeOne.getFullYear()
      let month = timeOne.getMonth() + 1
      let day = timeOne.getDate()
      month = month < 10 ? '0' + month : month
      day = day < 10 ? '0' + day : day
      return year+''+month+''+day
    },
    /** 查询评估主列表 */
    getFilters(){
      let obj = {statusStr:"1",pingname:this.queryParams.pingname};
      queryFiltration(obj).then(data=>{
        this.filter = data.rows;
      })
    },
    getList() {
      if(this.queryParams.sqrq!=null && this.queryParams.sqrq.length!=0){
          this.queryParams.sqsjFront = this.getNowDate(this.queryParams.sqrq[0])
          this.queryParams.sqsjBack = this.getNowDate(this.queryParams.sqrq[1])
      }else{
        this.queryParams.sqsjFront = null;
        this.queryParams.sqsjBack = null;
      }
      if(this.queryParams.dateTime!=null && this.queryParams.dateTime.length!=0){
          this.queryParams.completeStart = this.queryParams.dateTime[0].getTime()/1000
          this.queryParams.completeEnd = this.queryParams.dateTime[1].getTime()/1000
      }else{
        this.queryParams.completeStart = null;
        this.queryParams.completeEnd = null;
      }
      this.getFilters();
      this.loading = true;
      this.queryParams.status = 1;
      this.queryParams.pingnames = this.querFilter;
      this.queryParams.ispays = this.ispays;
      this.queryParams.pgdjs = this.pgdj;
      if(this.statuss!=null && this.statuss.length == 2){
         this.queryParams.isluru = null;
      }else{
         if(this.statuss!=null && this.statuss.length>0){
          if(this.statuss.indexOf("已录入")!=-1){
            this.queryParams.isluru = 1;
          }else if(this.statuss.indexOf("已评估")!=-1){
            this.queryParams.isluru = 0;
          }
          }else{
          this.queryParams.isluru = null;
        }
      }
      listMain(this.queryParams).then(response => {
        this.mainList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    successSendOrder(response, file, fileList){
      console.log(response.data);
      this.batchUpdateLevel= false;
      if(null != response.data.distinct){
          
          this.$message({
          message: '重复数据'+String(response.data.distinct)+'; 成功：'+response.data.success+';失败：'+response.data.failure+';总条数：'+response.data.total,
          type: 'success'
        });
      }else{
        this.$message({
          message: '成功：'+response.data.success+';失败：'+response.data.failure+';总条数：'+response.data.total,
          type: 'success'
        });
      }
        this.getList();
    },
    showCause(value){
      this.$alert(value,'原因', {
          confirmButtonText: '确定',
          callback: action => {
          }
        });

    },
    showUpdateImage(val){
      this.imageObject={
        id: val.id,
        image1:val.image1,
        image2:val.image2,
        image3:val.image3,
        image4:val.image4,
        image5:val.image5,
        image6:val.image6
      }
      this.updateImage = true;
    },
    delteList(index){
      this.$delete(this.updateAssessRenList,index);
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    setNeighborhoodCommittee(){
      this.form.juweiId = null;
      for(let i = 0;i<this.streetList.length;i++){
        if(this.streetList[i].id == this.form.streetid){
          this.neighborhoodCommittee = this.streetList[i].list;
          return;
        }
      }
    },
    setNeighborhoodCommittee2(){
      this.queryParams.juweiId = null;
      this.neighborhoodCommittee2 = [];
      for(let i = 0;i<this.streetList.length;i++){
        if(this.streetList[i].id == this.queryParams.streetid){
          this.neighborhoodCommittee2 = this.streetList[i].list;
          return;
        }
      }
    },
    formatDate: function(value,args) {

        if(value == null || value == ""){
          return;
        }
        if(args == null || args == ""){
          args = "yyyy-MM-dd HH:mm:ss"
        }
        var dt = new Date(value*1000);
        if(args == 'yyyy-M-d') {// yyyy-M-d
            let year = dt.getFullYear();
            let month = dt.getMonth() + 1;
            let date = dt.getDate();
            return `${year}-${month}-${date}`;
        } else if(args == 'yyyy-M-d H:m:s'){// yyyy-M-d H:m:s
            let year = dt.getFullYear();
            let month = dt.getMonth() + 1;
            let date = dt.getDate();
            let hour = dt.getHours();
            let minute = dt.getMinutes();
            let second = dt.getSeconds();
            return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
        } else if(args == 'yyyy-MM-dd') {// yyyy-MM-dd
            let year = dt.getFullYear();
            let month = (dt.getMonth() + 1).toString().padStart(2,'0');
            let date = dt.getDate().toString().padStart(2,'0');
            return `${year}-${month}-${date}`;
        } else {// yyyy-MM-dd HH:mm:ss
            let year = dt.getFullYear();
            let month = (dt.getMonth() + 1).toString().padStart(2,'0');
              if(month.length>2){
              month = month.replace("0","");
            }
            let date = dt.getDate().toString().padStart(2,'0');
            if(date.length>2){
              date = date.replace("0","");
            }
            let hour = dt.getHours().toString().padStart(2,'0');
            let minute = dt.getMinutes().toString().padStart(2,'0');
            let second = dt.getSeconds().toString().padStart(2,'0');
            return `${year}-${month}-${date} ${hour}:${minute}:${second}`;
        }
    },
    setNeighborhoodCommittee3(){
      let id = this.updateNeighborhooCommitteeObj.id;
      let streetid = this.updateNeighborhooCommitteeObj.streetid;
      this.updateNeighborhooCommitteeObj = {"id":id,"streetid":streetid,juweiId:null};
      for(let i = 0;i<this.streetList.length;i++){
        if(this.streetList[i].id == this.updateNeighborhooCommitteeObj.streetid){
          this.neighborhoodCommittee3 = this.streetList[i].list;
          return;
        }
      }
    },
    updateJieWei(){
       updateMain(this.updateNeighborhooCommitteeObj).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.updateNeighborhooCommittee = false;
              this.getList();
        });
    },
    showRemark(value){
      this.remark = true;
      this.remarkObj.fid = value;
      this.selectRemark(value);
    },
    selectRemark(val){
        if(val == null){
          return;
        }
        queryRemarkList({"fid":val}).then(response => {
          this.remarkList = response.rows;
        });
    },
    zizujian(value){
      console.log(this.$refs.ASSESSNEBT)
      this.$refs.ASSESSNEBT.getInfo(value.id);
    },
    addRemarkMethods(){
      let id  = this.remarkObj.fid;
      addRemark(this.remarkObj).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.selectRemark(id);
        });
    },
    // 表单重置
    reset() {
       this.form = {
        id: null,
        oid: null,
        pinguid: null,
        pinguidwait: null,
        pingname: null,
        pingnameisedit: null,
        streetid: null,
        juweiId: null,
        ptype: null,
        dtime: null,
        adr: null,
        name: null,
        contact: null,
        contact2: null,
        status: 0,
        sldate: null,
        pgdate: null,
        pdate: null,
        image1: null,
        image2: null,
        image4: null,
        image3: null,
        buchong: null,
        buchong2: null,
        sqh: null,
        xh: null,
        xm: null,
        xb: null,
        csny: null,
        sfzh: null,
        sbkh: null,
        sxdz: null,
        zzqx: null,
        zzjd: null,
        zzjw: null,
        dhhm: null,
        sjhm: null,
        dbrxm: null,
        dbrdhhm: null,
        dbrsjhm: null,
        dbrsfzh: null,
        pglx: null,
        pgsj: null,
        sjd: null,
        fwlx: null,
        sqsj: null,
        pgdj: null,
        yupgdj: null,
        suctime: null,
        cancelreason: null,
        canceluid: null,
        canceltime: null,
        cancelconfrimUid: null,
        statusInfo: null,
        lasteditTime: null,
        lasteditUid: null,
        submtime: null,
        pgdjStatus: "0",
        ispay: null,
        isluru: null,
        sblx: null,
        lastSavetime: null,
        yytime: null,
        ispai: null,
        lastSavetimeA: null,
        lastSavetimeB: null,
        aFinish: null,
        paidanTime: null,
        remark: null,
        manyi: null,
        manyiYuanyin: null,
        qianzi: null,
        bFinish: null,
        jiesuan: null,
        pjtime: null,
        image5: null,
        image6: null,
        gsdate: null,
        orderDate: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams={
        juweiId:null,
        pageNum: 1,
        pageSize: 10,
        type: null,
        streetid:null,
        serialNumber: null,
        requestCode: null,
        assesseeName: null,
        assesseeLandlinePhone: null,
        assesseePhone: null,
        assesseeSex: null,
        assesseeIdCard: null,
        assessessType: null,
        agentName: null,
        agentLandlinePhone: null,
        agentPhone: null,
        agentIdCard: null,
        socialSecurityCardNumber: null,
        socialSecurityType: null,
        serviceType: null,
        evaluatorIdOne: null,
        evaluatorOneName: null,
        evaluatorIdTwo: null,
        evaluatorTwoName: null,
        streetId: null,
        streetName: null,
        committeeId: null,
        committeeName: null,
        appointmentTime: null,
        assessCompletionTime: null,
        sendSingleTime: null,
        label: null,
        payoutStatus: null,
        forecastLevel: null,
        assessLevel: null,
        operationTotal: null,
        reasonCancellation: null,
        isRemark: null,
      };
      this.handleQuery();
    },
    getstreet() {
      listStreet({}).then(response => {
        this.streetList = response.rows;
      });
    },
    onSubmit(){
      if(this.updateStatusObj.pgwcsj!=null){
        this.updateStatusObj.suctime =this.updateStatusObj.pgwcsj.getTime()/1000; 
      }
       updateMain(this.updateStatusObj).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.updateStatus = false;
              this.getList();
        });
    },
   formatDateStr(timestamp) {
      if(timestamp == null || timestamp == '' || timestamp== 0){
        return;
      }
       // 计算年月日时分的函数
       var date = new Date(timestamp);
      var timeStr = date.getFullYear() + '-';
      if(date.getMonth() < 9) {
        //月份从0开始的
        timeStr += '0';
      }
      timeStr += date.getMonth() + 1 + '-';
      timeStr += date.getDate() < 10 ? ('0' + date.getHours()) : date.getHours();
      timeStr += ' ';
      timeStr += date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours();
      timeStr += ':';
      timeStr += date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes();
      timeStr += ':';
      timeStr += date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds();
      return timeStr;
   },
    download(){
     let obj = {};
      if(this.queryParams.sqrq!=null && this.queryParams.sqrq.length!=0){
          obj.sqsjFront = this.getNowDate(this.queryParams.sqrq[0])
          obj.sqsjBack = this.getNowDate(this.queryParams.sqrq[1])
      }else{
        this.queryParams.sqsjFront = null;
        this.queryParams.sqsjBack = null;
      }
      if(this.queryParams.dateTime!=null && this.queryParams.dateTime.length!=0){
          this.queryParams.completeStart = this.queryParams.dateTime[0].getTime()/1000
          this.queryParams.completeEnd = this.queryParams.dateTime[1].getTime()/1000
      }else{
        this.queryParams.completeStart = null;
        this.queryParams.completeEnd = null;
      }
      this.queryParams.status =1;
      if(this.querFilter!=null && this.querFilter.length !=0){
        this.queryParams.pingnames2 = this.querFilter.join("*");
      }
       for(let key in  this.queryParams){ 
        if(this.queryParams[key]!=null && this.queryParams[key]!=""){
            obj[key] =this.queryParams[key]; 
        }
      }
      obj.pingnames = null;
      obj.dateTime = null
      axios({
        method: 'get',
        url: this.downloadUrl+"?"+qs.stringify(obj),
        headers: { 'Content-Type': 'application/json' },
        responseType: 'blob',
        params: obj
        }).then(({data}) => {
          const blob = new Blob([data])
          const fileName = "评估结果-已评估 "+this.formatDate(new Date())+'.xlsx'
          const linkNode = document.createElement('a')

          linkNode.download = fileName // a标签的download属性规定下载文件的名称
          linkNode.style.display = 'none'
          linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
          document.body.appendChild(linkNode)
          linkNode.click() // 模拟在按钮上的一次鼠标单击
          URL.revokeObjectURL(linkNode.href) // 释放URL 对象
          document.body.removeChild(linkNode)
      })
    },
    xia(value){
    axios({
            method: 'get',
            url: this.xiaUrl+"?id="+value.id,
            headers: { 'Content-Type': 'application/json' },
            responseType: 'blob',
            }).then(({data}) => {
              const blob = new Blob([data])
              const fileName = value.sqh+""+this.dateformat(new Date())+'.xlsx'
              const linkNode = document.createElement('a')

              linkNode.download = fileName // a标签的download属性规定下载文件的名称
              linkNode.style.display = 'none'
              linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
              document.body.appendChild(linkNode)
              linkNode.click() // 模拟在按钮上的一次鼠标单击
              URL.revokeObjectURL(linkNode.href) // 释放URL 对象
              document.body.removeChild(linkNode)
          })
    },
    dateformat(date) {
       // 计算年月日时分的函数
      var timeStr = date.getFullYear() + '-';
      if(date.getMonth() < 9) {
        //月份从0开始的
        timeStr += '0';
      }
      timeStr += date.getMonth() + 1 + '-';
      timeStr += date.getDate() < 10 ? ('0' + date.getHours()) : date.getHours();
      timeStr += ' ';
      return timeStr;
   },
    dateTimeformat(val){
        if(val == undefined || val == null || val == 0){
          return null;
        }
        let date = new Date(val*1000);
        let timeStr = date.getFullYear() + '-';
        if(date.getMonth() < 9) {
          //月份从0开始的
          timeStr += '0';
        }
        timeStr += date.getMonth() + 1 + '-';
        timeStr += date.getDate() < 10 ? ('0' + date.getHours()) : date.getHours();
        timeStr += ' ';
        timeStr += date.getHours() < 10 ? ('0' + date.getHours()) : date.getHours();
        timeStr += ':';
        timeStr += date.getMinutes() < 10 ? ('0' + date.getMinutes()) : date.getMinutes();
        timeStr += ':';
        timeStr += date.getSeconds() < 10 ? ('0' + date.getSeconds()) : date.getSeconds();
        return timeStr;
      },
      handleAvatarSuccessImage1(res, file) {
        this.imageObject.image1 = res.data;
      },
      handleAvatarSuccessImage2(res, file) {
        this.imageObject.image2 = res.data
      },
      handleAvatarSuccessImage3(res, file) {
        this.imageObject.image3 = res.data
      },
      handleAvatarSuccessImage4(res, file) {
        this.imageObject.image4 = res.data
      },
      handleAvatarSuccessImage5(res, file) {
        this.imageObject.image5 = res.data
      },
      handleAvatarSuccessImage6(res, file) {
        this.imageObject.image6 = res.data
      },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    beforeAvatarUpload(file) {
        const isLt2M = file.size / 1024 / 1024 < 10;
        if (!isLt2M) {
          this.$message.error('上传头像图片大小不能超过 10MB!');
        }
        return isLt2M;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();

      this.open = true;
      this.title = "添加";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getMain(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateMain(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addMain(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    updateImages(){
      
      updateImage(this.imageObject).then(response => {
        this.updateImage = false;
        this.getList();
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除评估主编号为"' + ids + '"的数据项？').then(function() {
        return delMain(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$modal.confirm('是否确认导出所有评估主数据项？').then(() => {
        this.exportLoading = true;
        return exportMain(queryParams);
      }).then(response => {
        this.$download.name(response.msg);
        this.exportLoading = false;
      }).catch(() => {});
    }
  }
};
</script>

<style>
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 178px;
    height: 178px;
    display: block;
  }
  .el-table .cell {
 	  white-space: nowrap;
  	overflow: hidden;
  	text-overflow: ellipsis;
  }
  
</style>


<style scoped>
 ::v-deep .el-form-item--mini.el-form-item{
    margin-bottom: 10px !important;
    
  }
  ::v-deep .el-form-item__label{
    /* font-size: 20px !important; */
  }
  ::v-deep .el-table .el-table__cell{
    padding: 0;
  }
  ::v-deep .el-table .cell{
    padding: 0;
  }
    ::v-deep .el-form-item--mini.el-form-item{
    margin-bottom: 2px !important
  }
</style>